<template>
    <div class="head">
        <div class="title"
            :style="{ backgroundColor: '#EDEDED' , color: $store.state.winScroll > 100 || show ? '#000' : '#fff' }">
            <img v-if="!show" @click="show = true" class="close" src="@/assets/img/open.png" alt="">
            <img v-else class="close" @click="show = false" src="@/assets/img/close.png" alt="">
            <img @click="goPage('/index')" src="@/assets/img/logo3.png" alt="">
        </div>
        <div class="menu" :style="{ height: show ? '' : '0' }">
            <mobMenu :show="show" @close="close"></mobMenu>
        </div>
        <div class="right">
            <div @click="drawer = true">
                <img src="@/assets/img/kefu2.png" alt="">
                <span>客服</span>
            </div>
            <router-link style="text-decoration: none;" :to="{ name: 'feadback' }" >
                <div class="feadback">
                    <img src="@/assets/img/feadback.png" alt="">
                    <span>反馈</span>
                </div>
            </router-link>

            <div @click="top" class="goTop" v-if="$store.state.winScroll > 200">
                <img src="@/assets/img/top.png" alt="">
                <span>回顶部</span>
            </div>
        </div>
        <el-drawer show-close size="20%" :withHeader="false" :modal-append-to-body="false" :visible.sync="drawer"
            direction="btt">
            <div class="online">
                <img src="@/assets/img/cusicon.png" alt="">
                <img @click="drawer = false" class="close" src="@/assets/img/close.png" alt="">
                <div>
                    <p>在线客服</P>
                    <span class="tel">{{ options.kf_phone }}</span>
                    <span class="onlinetime">{{ options.kf_worktime }}</span>
                </div>
            </div>
        </el-drawer>
    </div>
</template>

<script>
import mobMenu from './mobMenu.vue';
export default {
    components: {
        mobMenu
    },
    data() {
        return {
            show: false,
            drawer: false
        }
    },
    computed: {
        options() {
            return this.$store.state.dataInfo
        }
    },
    methods: {
        top() {
            window.scrollTo({
                top: 0,
                behavior: 'smooth' // 平滑滚动
            });
        },
        close() {
            this.show = false
        },
        goPage(url) {
            if (url) {
                this.$router.push(url)
                this.$emit('close')
            }
            this.close()

        },
    },
    watch: {
        '$route'() {
            this.close()
        },
        show(n) {
            if (n) {
                document.body.style.overflow = 'hidden'
            } else {
                document.body.style.overflow = ''
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.head {
    // position: fixed;
    position: sticky;
    top: 0;
    z-index: 99;
    width: 100%;
}

.title {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 279px;
    z-index: 99;
    width: 100%;

    i {
        position: absolute;
        left: 165px;
        font-size: 80px;
    }

    .close {
        width: 82px;
        height: 75px;
        position: absolute;
        left: 165px;
    }

    img {
        width: 196px;
        height: 196px;
    }
}

.menu {
    position: fixed; 
    top: 279px;
    left: 0; 
    height: calc(100vh - 279px);
    padding: 0 80px;
    overflow-y: auto;
    width: 100%;
    overflow-x: hidden;
    background-color: #fff;
    // position: relative;

    /*滚动条样式*/
    &::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 0.26042vw !important;
        /*高宽分别对应横竖滚动条的尺寸*/
        height: 0.26042vw !important;
    }

    &::-webkit-scrollbar-thumb {
        /*滚动条里面小方块*/
        border-radius: 0.26042vw !important;
        -webkit-box-shadow: inset 0 0 0.26042vw rgba(0, 0, 0, 0.2) !important;
        background: rgba(0, 0, 0, 0.2) !important;
    }

    &::-webkit-scrollbar-track {
        /*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 0.26042vw rgba(0, 0, 0, 0.2) !important;
        border-radius: 0 !important;
        background: rgba(0, 0, 0, 0.1) !important;
    }


}

.kefu {
    position: fixed;
    bottom: 270px;
    right: 80px;
    width: 200px;
    height: auto;
}

.online {
    border-radius: 40px;
    padding: 140px 120px;
    display: flex;
    position: relative;

    .close {
        position: absolute;
        right: 30px;
        top: 60px;
        width: 80px;
        height: 80px;
    }

    img {
        width: 160px;
        height: 160px;
        margin-right: 80px;
        flex-shrink: 0;
    }

    div {
        display: flex;
        flex-direction: column;
        font-family: MiSans;
        font-weight: 400;
        font-size: 80px;
        width: 1000px;

        p {
            margin: 0;
            padding: 0;
            color: #000;
        }

        .tel {
            margin: 10px 0;
            color: #B00D16;
        }

        .go {
            margin-top: 40px;
            color: #B00D16;
            font-weight: 500;
            font-size: 72px;
            cursor: pointer;
        }
    }
}

.right {
    width: 200px;
    position: fixed;
    right: 0;
    top: 50%;
    z-index: 98;
    background-color: #fff;
    border-radius: 35px 0 0 30px;
    padding: 10px 6px 10px;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;

    >div,
    .feadback {
        cursor: pointer;
        display: flex;
        align-items: center;
        flex-direction: column;
        justify-content: center;
        font-family: MiSans;
        font-weight: 400;
        font-size: 40px;
        color: #2c2c2c;
        margin-bottom: 45px;
        font-weight: bold;
        text-decoration: none;

        &:last-child {
            margin: 0;
        }

        &:first-child {
            img {
                width: 95px;
                height: auto;
            }
        }

        span {
            text-decoration: none;
        }

        img {
            width: 100px;
            height: auto;
            margin-bottom: 20px;

        }
    }
    .goTop{
        margin-top: 45px !important;
        img{
            width:90px;
        }
    }
}

::v-deep .el-drawer {
    border-radius: 60px 60px 0 0;
}
</style>